//
// Created by andrew on 2024/9/24.
//

#include <string>
#include <vector>
#include <unordered_set>

#include <iostream>
#include <gtest/gtest.h>
#include <climits>

using namespace std;





class Solution {
public:
    int reverse(int x) {
        long ret = 0;
        while(x != 0) {
            ret = ret * 10 + x % 10;
            x /= 10;
        }
        return (ret < INT_MIN || ret > INT_MAX) ? 0 : ret;
    }
};

class Solution1 {
public:
    int reverse(int x) {
        int ret = 0;
        while(x != 0) {
            ret = ret * 10 + x % 10;
            x /= 10;
        }

        return (ret < INT_MIN || ret > INT_MAX) ? 0 : ret;
    }

};



TEST(leetcode7, leetcode) {

    Solution1 solution_1;
    EXPECT_EQ(123, solution_1.reverse(321));

}

